package leet.ku._203;

class ListNode {
	int val;
	ListNode next;

	ListNode(int x) {
		val = x;
	}
}

public class Solution {
	public ListNode removeElements(ListNode head, int val) {
		if (head == null)
			return null;
		ListNode now = head;
		while (now.next != null) {
			if (now.next.val == val)
				now.next = now.next.next;
			else
				now = now.next;
		}
		if (head.val == val)
			return head.next;
		else
			return head;
	}
}